<?php 
$this->breadcrumbs=array(
	'Deals'=>array('deal/admin'),
	//$model->attachment->customer->getFullName()=>array('customer/view','id'=>$model->attachment->customerId),
	$model->attachment->deal->referenceNo=>array('deal/view','id'=>$model->attachment->dealId),
	'Attachments'=>array('attachment/admin','dealId'=>$model->attachment->dealId),
	$model->attachment->name=>array('attachment/view','id'=>$model->attachmentId),
	'Upload File'
);
?>

<h1>Batch Upload File of <?php echo $model->attachment->name;?> for Deal <?php echo $model->attachment->deal->referenceNo;?></h1>
<?php
Yii::app()->clientScript->registerCoreScript('jquery');
$this->widget('ext.plupload.PluploadWidget', array(
	'config' => array(
		//'runtimes' => 'html5',
		'url' => $this->createUrl('attachmentFile/uploadFilesPlupload'),
		//'max_file_size' => str_replace("M", "mb", ini_get('upload_max_filesize')),
		//'max_file_size' => Yii::app()->params['maxFileSize'],
		'chunk_size' => '1mb',
		'unique_names' => true,
		//'filters' => array(array('title' => 'SMR Files', 'extensions' => 'smr'),),
		'browse_button'=>'uploadButton',
		//'language' => 'en-smr',
		'max_file_number' => 20,
		'autostart' => false,
		'jquery_ui' => true,
		'browse_button'=>'uploader_browse',
		'reset_after_upload' => false,
		//using this flag to disable CSRF validation for uploads
		'headers'=>array('XUPLOAD'=>"true"),
	),
	'callbacks' => array(
		'FileUploaded' => 'function(up,file,response){
		up.refresh();
		jQuery.post( "'.$this->createUrl('attachmentFile/uploadFilesInfo',array('attachmentId'=>$model->attachment->id)).'", {id:file.id,name:file.name}, function(data, textStatus, jqXHR){
			var filename=data;
			$("#uploaded-file-list").append("<li>"+filename+"</li>");
		},"json" );
		}',
		),
	'id' => 'uploader'
	)
);
?>
<div style="margin-top: 20px;">
<h3>Uploaded Files:</h3>
<ul id="uploaded-file-list">
</ul>
</div>